package alo.p12.work;

/**
 * @ClassName FindWithPairComparison
 * @Description 寻找最小值和最大值
 * @Author Fanxc
 * @DATE 2021/3/14 10:50
 * @Version 1.0
 */
public class FindWithPairComparison {
    void findWithPairComparison(int[] A,int n){
        int large,small;
        large=small=-1;
        for (int i = 0; i < n - 1; i=i+2) {
            if (A[i]<A[i+1]){
                if (A[i]<small){
                    small=A[i];
                }
                if (A[i+1]>large){
                    large=A[i+1];
                }
            }else {
                if (A[i+1]<small){
                    small=A[i+1];
                }
                if (A[i]>large){
                    large=A[i];
                }
            }
        }
        System.out.println("small:  "+small+" large:  "+large);
    }
}
